const app = getApp()
Page({
  data: {
    count7: 0,
    count10: 0,
    count12: 0,
    count15: 0,
    count20: 0,
    showStr: "您还没有点餐,请开始点餐",
    description: "无"
  },
  descriptionInput: function (e) {
    this.setData({
      description: e.detail.value
    });
  },
  descConfirm: function (e) {
    console.log(e);
  },
  orderFoodBtn: function () {

    if (this.data.count7 + this.data.count10 + this.data.count12 + this.data.count15 + this.data.count20 > 0) {
      wx.setStorageSync("orderContent", this.data.showStr);
      wx.setStorageSync("orderDescription", this.data.description);
      wx.navigateTo({
        url: 'showWant/index'
        // url: 'showWant/index?orderContent=' + this.data.showStr + '&orderDescription=' + this.data.description
      })
    } else {
      wx.showModal({
        title: '您还没有点餐',
        content: "请先点餐后，然后再确认订单",
        showCancel: false
      })
    }

  },
  orderShow: function () {
    let hasCheck = "";
    if (this.data.count7 + this.data.count10 + this.data.count12 + this.data.count15 + this.data.count20 == 0) {
      this.setData({
        showStr: "您还没有点餐,请开始点餐"
      });
    } else {
      if (this.data.count7 > 0) hasCheck += "7元套餐" + this.data.count7 + "份;\n";
      if (this.data.count10 > 0) hasCheck += "10元套餐" + this.data.count10 + "份;\n";
      if (this.data.count12 > 0) hasCheck += "12元套餐" + this.data.count12 + "份;\n";
      if (this.data.count15 > 0) hasCheck += "15元套餐" + this.data.count15 + "份;\n";
      if (this.data.count20 > 0) hasCheck += "20元套餐" + this.data.count20 + "份\n";
      this.setData({
        showStr: hasCheck
      });
    }
  },
  countChange10: function ({ detail }) {
    this.setData({
      count10: detail.value
    });
    this.orderShow();
  },
  countChange7: function ({ detail }) {
    this.setData({
      count7: detail.value
    });
    this.orderShow();
  },

  countChange10: function ({ detail }) {
    this.setData({
      count10: detail.value
    });
    this.orderShow();
  },
  countChange12: function ({ detail }) {
    this.setData({
      count12: detail.value
    });
    this.orderShow();
  },
  countChange15: function ({ detail }) {
    this.setData({
      count15: detail.value
    });
    this.orderShow();
  },
  countChange20: function ({ detail }) {
    this.setData({
      count20: detail.value
    });
    this.orderShow();
  },
  onLoad: function () {

  }
})